package com.nxw.springcloud.admin.entity;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class RateLimitConfig {

    private String routeId;
    private Map<String, Config> tokenConfig;

    public String getRouteId() {
        return routeId;
    }

    public void setRouteId(String routeId) {
        this.routeId = routeId;
    }

    public Map<String, Config> getTokenConfig() {
        return tokenConfig;
    }

    public void setTokenConfig(Map<String, Config> tokenConfig) {

        this.tokenConfig = tokenConfig;
    }

    public static class Config {
        private int replenishRate;
        private int burstCapacity;
        private int timeType;
        public Config() {
        }

        public int getReplenishRate() {
            return this.replenishRate;
        }

        public Config setReplenishRate(int replenishRate) {
            this.replenishRate = replenishRate;
            return this;
        }

        public int getBurstCapacity() {
            return this.burstCapacity;
        }

        public Config setBurstCapacity(int burstCapacity) {
            this.burstCapacity = burstCapacity;
            return this;
        }

        public int getTimeType() {
            return timeType;
        }

        public void setTimeType(int timeType) {
            this.timeType = timeType;
        }

        public String toString() {
            return "Config{replenishRate=" + this.replenishRate + ", burstCapacity=" + this.burstCapacity + '}';
        }

    }

    public static void main(String[] args) {
        RateLimitConfig rateLimitConfig = new RateLimitConfig();
        rateLimitConfig.setRouteId("consumer-service");
        Map<String, Config> map = new HashMap<>();
        Config config = new Config();
        config.setBurstCapacity(100);
        config.setReplenishRate(100);
        config.setTimeType(4);
        Config config2 = new Config();
        config2.setBurstCapacity(100);
        config2.setReplenishRate(100);
        config2.setTimeType(4);
        map.put("clientIp",config);
        map.put("appKeyAndSecret",config2);

        rateLimitConfig.setTokenConfig(map);

        String s = JSONObject.toJSONString(rateLimitConfig);
        System.out.println(s);
    }
}